//
//  WzzMainTBVc.m
//  Wb_oc
//
//  Created by wzz on 16/7/21.
//  Copyright © 2016年 wzz. All rights reserved.
//

#import "WzzMainTBVc.h"
#import "WzzHomeVc.h"
#import "WzzDiscoverVc.h"
#import "WzzMessageVc.h"
#import "WzzProfileVc.h"
#import "WzzZdyTaBar.h"
#import "WzzCenterController.h"


@interface WzzMainTBVc ()

@end

@implementation WzzMainTBVc

- (void)viewDidLoad {
    [super viewDidLoad];

    //自定义tabBar
    WzzZdyTaBar * tabBar = [[WzzZdyTaBar alloc]init];
    [self setValue:tabBar forKey:@"tabBar"];
    
    //__weak typeof(self) weakSelf = self;
    tabBar.centerButBlock = ^{
    
        WzzCenterController * centerVc = [[WzzCenterController alloc]init];
        [self presentViewController:centerVc animated:true completion:nil];
    };
    
    [self setupUI];

}


- (void)setupUI{
    
    WzzHomeVc * hvc = [WzzHomeVc new];
    WzzDiscoverVc * dvc = [WzzDiscoverVc new];
    WzzMessageVc * mvc = [WzzMessageVc new];
    WzzProfileVc * pvc = [WzzProfileVc new];
    [self addChildViewController:hvc withTitle:@"首页" withImgName:@"tabbar_home"];
    [self addChildViewController:dvc withTitle:@"发现" withImgName:@"tabbar_discover"];
    [self addChildViewController:mvc withTitle:@"消息" withImgName:@"tabbar_message_center"];
    [self addChildViewController:pvc withTitle:@"我" withImgName:@"tabbar_profile"];
    

}

- (void)addChildViewController:(UIViewController *)childController withTitle:(NSString *)title withImgName:(NSString *)imgName{
    
    childController.title = title;

    childController.tabBarItem.image = [UIImage imageNamed:imgName];
    childController.tabBarItem.selectedImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",imgName]];
    
    
    UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:childController];
    [self addChildViewController:nav];
    
}


@end
